package table.creators;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import controllers.AuthorHelper;
import models.Part_consume;
import models.Staff;
import models.Staff;
import models.Vehicle;
import controllers.Helper;
import controllers.TableModel;
import controllers.TableModel.AoColum;

public class Part_consumeTable {

    public static TableModel create(String current_user) {
        final String USE_TYPE = "|更换|修理|添加";
    
        final String title = "汽配领用";
        String today = Helper.dateToString(new Date());
        String now = Helper.datetimeToString(new Date());

        List<AoColum> colums = new ArrayList<AoColum>();
        TableModel model = new TableModel();

        //                           name,             title,         required,     defaut,        cansearch, editable,    edit_type,    edit_data,            editable_settings    
        if(AuthorHelper.isInRoleGroup(current_user, "0")) {
           colums.add(model.new AoColum("id",    "编号",    false,    "",    false,    false,    "edit",    null,    null,  "ONEBOX",  "",  "",  "",   "",   "",   "",  false));
        }
        if(AuthorHelper.isInRoleGroup(current_user, "0")) {
           colums.add(model.new AoColum("material",    "材料名称、型号、品牌",    true,    "",    true,    AuthorHelper.isInRoleGroup(current_user, "0"),    "edit",    null,    null,  "ONEBOX",  "",  "",  "",   "",   "",   "",  false));
        }
        if(AuthorHelper.isInRoleGroup(current_user, "0")) {
           colums.add(model.new AoColum("unit_price",    "单价",    true,    "",    true,    AuthorHelper.isInRoleGroup(current_user, "0"),    "edit",    null,    null,  "TWOBOX",  "",  "",  "",   "",   "",   "",  false));
        }
        if(AuthorHelper.isInRoleGroup(current_user, "0")) {
           colums.add(model.new AoColum("invoice_number",    "发票号/收据单号",    true,    "",    true,    AuthorHelper.isInRoleGroup(current_user, "0"),    "edit",    null,    null,  "ONEBOX",  "",  "",  "",   "",   "",   "",  false));
        }
        if(AuthorHelper.isInRoleGroup(current_user, "0")) {
           colums.add(model.new AoColum("inventory",    "存库数量",    true,    "",    true,    AuthorHelper.isInRoleGroup(current_user, "0"),    "edit",    null,    null,  "TWOBOX",  "",  "",  "",   "",   "",   "",  false));
        }
        if(AuthorHelper.isInRoleGroup(current_user, "0")) {
           colums.add(model.new AoColum("consume_quantity",    "领用数量",    true,    "",    true,    AuthorHelper.isInRoleGroup(current_user, "0"),    "edit",    null,    null,  "TWOBOX",  "",  "",  "",   "",   "",   "",  false));
        }
        if(AuthorHelper.isInRoleGroup(current_user, "0")) {
           colums.add(model.new AoColum("consume_day",    "领料日期",    true,    today,    true,    AuthorHelper.isInRoleGroup(current_user, "0"),    "date",    null,    null,  "TWOBOX",  "",  "",  "",   "",   "",   "",  false));
        }
        if(AuthorHelper.isInRoleGroup(current_user, "0")) {
           colums.add(model.new AoColum("consume_person.name",    "领料人",    true,    "",    true,    AuthorHelper.isInRoleGroup(current_user, "0"),    "select",    Staff.getNameJson(),    null,  "ONEBOX",  "staff",  "name",  "",   "",   "",   "",  false));
        }
        if(AuthorHelper.isInRoleGroup(current_user, "0")) {
           colums.add(model.new AoColum("consume_number",    "领料单号",    true,    "",    true,    AuthorHelper.isInRoleGroup(current_user, "0"),    "edit",    null,    null,  "ONEBOX",  "",  "",  "",   "",   "",   "",  false));
        }
        if(AuthorHelper.isInRoleGroup(current_user, "0")) {
           colums.add(model.new AoColum("ship_person.name",    "发货人",    true,    "",    true,    AuthorHelper.isInRoleGroup(current_user, "0"),    "select",    Staff.getNameJson(),    null,  "ONEBOX",  "staff",  "name",  "",   "",   "",   "",  false));
        }
        if(AuthorHelper.isInRoleGroup(current_user, "0")) {
           colums.add(model.new AoColum("use_type",    "用途属性",    true,    "",    true,    AuthorHelper.isInRoleGroup(current_user, "0"),    "select",    Helper.getSelectOptionJson(USE_TYPE),    null,  "ONEBOX",  "",  "",  "",   "",   "",   "",  false));
        }
        if(AuthorHelper.isInRoleGroup(current_user, "0")) {
           colums.add(model.new AoColum("vehicle.plate_number",    "领用车号",    true,    "",    true,    AuthorHelper.isInRoleGroup(current_user, "0"),    "select",    Vehicle.getPlate_numberJson(),    null,  "ONEBOX",  "vehicle",  "plate_number",  "",   "",   "",   "",  false));
        }
        if(true) {
           colums.add(model.new AoColum("comments",    "领用说明",    true,    "",    false,    true,    "edit",    null,    null,  "ONEBOX",  "",  "",  "",   "",   "",   "",  false));
        }
        model.buildModel(Part_consume.class, 600, title, AuthorHelper.canDo(current_user, title, "增加"), AuthorHelper.canDo(current_user, title, "搜索"), AuthorHelper.canDo(current_user, title, "删除"), colums);
        return model;
    }
}

